<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<Title>Attachments</Title>
<link rel="STYLESHEET" type="text/css" href="styles.css">
</HEAD>
<BODY>
<h1>SOAP Attachments</h1>

<p>Transporting binary data (such as images, artibrary files, etc), via SOAP can be inefficient, as the data has be base64 encodeded and decoded, and is contained
within the SOAP message itself, which can increase the XML parsing overhead. To alleviate this, you can transport this data as attachments, so that it exists
outside of the SOAP message, and is not base64 encoded &amp; decoded.</p>

<p>PocketSOAP supports attachments using either <a href="http://www.w3.org/TR/SOAP-attachments">SOAP with Attachments</a> or 
<a href="http://search.ietf.org/internet-drafts/draft-nielsen-dime-02.txt">DIME</a></p>

<p>The SOAP with Attachments suport has been sucessfully tested against</p>
<ul>
<li><a href="http://xml.apache.org/axis">Apache Axis beta 1</a>
<li><a href="http://xml.apache.org/soap">Apache SOAP 2.2</a>
<li><a href="http://www.iona.com/products/webserv-xmlbus.htm">Orbix E2A(tm) XMLBus</a>
<li><a href="http://www.soaplite.com">SOAP::Lite</a>
<li><a href="http://soap.fmui.de/index.php">Spheon JSOAP</a>
</ul>
<p>The DIME support has been sucessfully tested against</p>
<ul>
<li><a href="http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/sample.asp?url=/msdn-files/027/001/948/msdncompositedoc.xml">MSTK 3.0</a>
<li><a href="http://www.whitemesa.com/">White Mesa</a>
<li><a href="http://discuss.develop.com/archives/wa.exe?A2=ind0202b&L=dime&F=&S=&P=57">Simon's test .NET Dime Server.</a>
<li><a href="http://soap.fmui.de/index.php">Spheon JSOAP</a>
<li>WSTK for ASP.NET
</ul>
<br>
<p>Making request's that include attachments</p>
The Attachments Manager object is the key point to making requests that include attachments, you use this object, to create attachments in the request, build and
send the request complete with attachments, and to parse attachments contained in the response. Here's a walk through of using the attachments manager to
make a call with attachments.</p>
<br><blockquote>
You need to indicate if you want to do DIME or MIME based attachments before you add any attachments.
<pre>set mgr = CreateObject("pocketSOAP.Attachments")
mgr.Format = formatDime</pre>

This creates a new attachment in the request collection, and returns it.
<pre>set att = mgr.Request.Create ("c:\image.gif", tnfMediaType, "image/gif")</pre>

Typically you assign the URI of the attachment to the href attribute of a parameter in the SOAP message
<pre>set n = e.parameters.create ("attachment", empty )
n.href = att.Uri</pre>

Create and configure the HTTP transport object as normal, then set the transport property on the attachment objects to the transport object
<pre>set t = CreateObject("pocketSOAP.HTTPTransport")
t.SetProxy "localhost", 7070
t.Soapaction = "http://xsd.prototypes.4s4c.com/dime/"
set mgr.Transport = t </pre>

Now we send through the attachments manager, rather than direct to the transport, the attachments manager will package everything
up in the required format and send it to the underlying transport object created earlier.
<pre>mgr.Send "http://soap.4s4c.com/dime/sf.soap", e.Serialize</pre>

Again, for the parsing end, the attachments manager is shimmed between the parser and the transport, so you call parse specifying the
attachments manager.
<pre>e.parse mgr</pre>

Finally, you use the href property on the node to get the URI of the response attachment, and then look for it in the response attachments
collection
<pre>href = e.parameters.Item(0).href
set theAttachment = mgr.response.find(href)

if theAttachment.Location = attInMemory then
	theAttachment.Save "c:\att.gif" 
end if
msgbox "attachment saved as " & theAttachment.Body</pre>

</blockquote>

<BR><BR><BR>
<h3>Copyright</h3>
<p>Copyright &copy; Simon Fell, 2002-2004. All rights reserved.<br>

</BODY>
</HTML>